#pragma once

class CriticalSection
{
public:
    CriticalSection();
    ~CriticalSection();

    void enter();

    void leave();

private:
    CRITICAL_SECTION critical_section_;
};

class CriticalSectionUtil
{
public:
    CriticalSectionUtil(CriticalSection &cs):
        cs_(cs)
    {
        cs_.enter();
    }

    ~CriticalSectionUtil() 
    {
        cs_.leave();
    }

private:
    CriticalSection &cs_;
};